import 'package:animal/constant/font.dart';
import 'package:animal/utils/screen_util.dart';
import 'package:animal/widgets/appbar_widget.dart';
import 'package:flutter/material.dart';
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
import 'package:get/get.dart';
import 'package:getwidget/getwidget.dart';

///商家服务价单Widget
class OpenServiceWidget extends StatelessWidget {
  OpenServiceWidget({Key? key}) : super(key: key);
  final controller = Get.put(OpenServiceController());
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBarWidget.defaultAppBar(
          title: Text("选择开通时间", style: KFontConstant.myTextStyle(size: 17)),
          elevation: 0,
          automaticallyImplyLeading: false,
          leading: Container(),
          backgroundColor: Colors.white,
          actions: [
            GFIconButton(
              icon: const Icon(Icons.highlight_remove_outlined),
              onPressed: () => SmartDialog.dismiss(),
              type: GFButtonType.transparent,
            )
          ],
          appBarHeight: ScreenUtil().L(30),
          primary: false),
      body: Obx(
        () => Column(
          children: _getCheckboxListTitle(),
        ),
      ),
    );
  }
  List<Widget> _getCheckboxListTitle() {
    return controller.data
        .map((item) => Flexible(
      child: GFCheckboxListTile(
        titleText: item["name"],
        size: ScreenUtil().L(25),
        activeBgColor: Colors.green,
        type: GFCheckboxType.circle,
        activeIcon: Icon(
          Icons.check,
          size: ScreenUtil().L(20),
          color: Colors.white,
        ),
        onChanged: (value) {
          SmartDialog.showToast("${item["name"]}");
        },
        value: false,
      ),
    ))
        .toList();
  }
}

class OpenServiceController extends GetxController {
  List<Map> data = [
    {"id": 1, "name": "¥ 88元/1个月"},
    {"id": 2, "name": "¥ 288元/1个月"},
    {"id": 3, "name": "¥ 588元/1个月"},
    {"id": 4, "name": "¥ 888元/1个月"},
  ];

  RxBool check = false.obs;
}
